package com.base.dehong.base;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;

import com.base.dehong.util.LogUtils;

@SuppressLint("NewApi")
public abstract class FragmentBaseFrame extends Fragment{
	public View mContentView;
	public DisplayMetrics dm;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		dm = new DisplayMetrics();
		getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
	}
	
	public final <E extends View> E getView(View parent, int id) {
		try {
			return (E) parent.findViewById(id);
		} catch (ClassCastException ex) {
			LogUtils.e("通过父类布局初始化化控件类转型异常", ex.getMessage().toString());
			throw ex;
		}
	}
	public final <E extends View> E getView(int id) {
		try {
			return (E) mContentView.findViewById(id);
		} catch (ClassCastException ex) {
			LogUtils.e("通过父类布局初始化化控件类转型异常", ex.getMessage().toString());
			throw ex;
		}
	}

	protected abstract void showProgressDialog();
	
	public abstract void disappearProgressDialog();
	
	 /**
	  * 从控件中获取文本
	  * @param view
	  * @return
	  * 作者： tangwenhan
	  * 时间 ：下午2:59:23
	  */
	 public String getStr4TextView(TextView view){
		 return view.getText().toString().trim();
	 }
}
